package com.example.happ.controller;

import com.example.happ.service.BlacklistInfoService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/blacklist")
public class blacklistController {
    @Resource
    private BlacklistInfoService blacklistInfoService;
    //添加黑名单
    @RequestMapping("/add")
    @CrossOrigin(origins = "http://localhost:8080")
    public Boolean addBlacklist(@RequestBody Map<String, String> requestBody) {
        Boolean result = blacklistInfoService.addBlacklists(requestBody);
        return result;
    }
    //查询所有黑名单用户
    @RequestMapping("/find")
    @CrossOrigin(origins = "http://localhost:8080")
    public Map<String, Object> findBlacklists(@RequestBody Map<String, String> requestBody) {
        return blacklistInfoService.findBlacklistsByMerchantId(requestBody);
    }
    //删除某个黑名单用户
    @RequestMapping("/delete")
    @CrossOrigin(origins = "http://localhost:8080")
    public boolean deleteBlacklist(@RequestBody Map<String, String> requestBody) {
        return blacklistInfoService.deleteBlacklistsByMerchantId(requestBody);
    }
}
